home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / utils / file / logiso.000 / logiso / Utils / check_links next >
Encoding:
Korn shell script  |  1995-03-24  |  1.1 KB  |  50 lines

  1. #! /bin/ksh
  2. USAGE='USAGE: check_links [ -d config_prefix ] [ ROOT_DIR ]
  3.    Check for links below ROOT_DIR which should be replaced and replace
  4.    them.
  5.    Uses ISOFS_UTIL_DIR and ${ISOFS_UTIL_DIR}/${CONFIG_PREFIX}config to set 
  6.    MOUNT_PATH and MAP_TO_PATH
  7. '
  8. # (C) Copyright 1995 by Michael Coulter.  All rights reserved.
  9.  
  10. # Process parameters
  11.  
  12.    CONFIG_PREFIX=""
  13.    if [ $# -ge 2 -a "$1" = "-d" ]
  14.    then
  15.       shift  # done with -d
  16.       CONFIG_PREFIX="$1"; shift
  17.    fi
  18.    if [ $# -gt 1 ]
  19.    then
  20.       echo "$USAGE" >&2
  21.       echo "Too many arguments." >&2
  22.       exit 1
  23.    fi
  24.    ROOT_DIR="/"
  25.    if [ $# -eq 1 ]
  26.    then
  27.       ROOT_DIR="$1"; shift
  28.    fi
  29.  
  30. # Set variables
  31.  
  32.    ISOFS_UTIL_DIR="${ISOFS_UTIL_DIR:-/usr/src/linux/fs/isofs/Utils}"
  33.    . "$ISOFS_UTIL_DIR/ksh_fns"
  34.    .  "${ISOFS_UTIL_DIR}/${CONFIG_PREFIX}config"
  35.    export ISOFS_UTIL_DIR
  36.  
  37. # Of the link files, find those which point to a file below $MOUNT_PATH and
  38. # for which the equivalent link exists below $MAP_TO_PATH
  39.  
  40. HERE="$PWD"
  41.  
  42. # Do it
  43.  
  44.    echo "Checking links below $ROOT_DIR"
  45.  
  46.    ${FIND_LINKS} "$ROOT_DIR" | while read FILE REST
  47.    do
  48.       check_one_link "$FILE" "$MOUNT_PATH" "$MAP_TO_PATH"
  49.    done
  50.